﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IP代理
{
    public static class FileHelp
    {


        /// <summary>
        /// 读取
        /// </summary>
        /// <returns></returns>
        public static List<string> GetFile(string path)
        {
            try
            {
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
                StreamReader sr = new StreamReader(fs, Encoding.Default);
                List<string> listStr = new List<string>();
                string str = sr.ReadLine();
                while (!string.IsNullOrEmpty(str))
                {
                    listStr.Add(str);
                    str = sr.ReadLine();
                }
                sr.Close();
                fs.Close();
                return listStr;
            }
            catch (Exception)
            {
                return null;
            }
        }

        /// <summary>
        /// 记录
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="mess"></param>
        public static void SaveFile(string FilePath, string str)
        {
            try
            {
                File.WriteAllText(FilePath, str, Encoding.Default);
            }
            catch (Exception)
            { }
        }
    }
}
